/**
 * @properties={typeid:35,uuid:"3744CC3E-510A-4EC4-813A-35D84EB09723",variableType:-4}
 */
var $NOMBRE_SERVIDOR = globals.$NOMBRE_SERVIDOR;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"1F7AE3A4-7CE6-42B9-872C-B457AE235D1D"}
 */
var $NOMBRE_TABLA = "adm_t700_frm";

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"3841790D-02E1-43D6-89E5-0AE552DC34EE"}
 */
var $DATA_SOURCE = "db:/" + $NOMBRE_SERVIDOR + "/" + $NOMBRE_TABLA;

/**
 * @param {UUID} adm_t900_usuarios_id
 *
 * @properties={typeid:24,uuid:"9DCCBAF0-42A6-483E-8916-1409885FE3A3"}
 * @AllowToRunInFind
 */
function borrar_historial(adm_t900_usuarios_id){
	
	/** @type {JSFoundSet<db:/pigeon_board/adm_t700_frm>}*/
	var fs_adm_t700_frm = databaseManager.getFoundSet($DATA_SOURCE);
	fs_adm_t700_frm.loadAllRecords();
	if (fs_adm_t700_frm.find()){
		fs_adm_t700_frm.adm_t900_usuarios_id = adm_t900_usuarios_id;
		fs_adm_t700_frm.search();
	}
	
	if (fs_adm_t700_frm.getSize()){
		fs_adm_t700_frm.deleteAllRecords();
	}
}

/**
 * @param {JSEvent} event
 * @param {String} frm
 *
 * @properties={typeid:24,uuid:"C8AB9BE2-D524-4411-81F5-B0EDD57B84D4"}
 */
function alta(event, frm){
	
	// Damos de alta el formulario
	/** @type {JSFoundSet<db:/pigeon_board/adm_t700_frm>} */
	var fs_adm_t700_frm = databaseManager.getFoundSet($DATA_SOURCE);
	fs_adm_t700_frm.newRecord();
	fs_adm_t700_frm.s_sql = databaseManager.getSQL(forms[event.getFormName()].foundset,true);
	databaseManager.saveData(fs_adm_t700_frm);
	
	// Damos de alta los parámetros del foundset
	/** @type {JSFoundSet<db:/pigeon_board/adm_t700_sql_params>} */
	var fs_adm_t700_sql_params = databaseManager.getFoundSet(scopes.adm_t700_sql_params.$DATA_SOURCE);
	var sql_params = databaseManager.getSQLParameters(forms[event.getFormName()],true);
	for (var x = 0; x < sql_params.length; x++){
		fs_adm_t700_sql_params.newRecord();
		fs_adm_t700_sql_params.adm_t700_frm_id = fs_adm_t700_frm.adm_t700_frm_id;
		fs_adm_t700_sql_params.s_sql_param = sql_params[x];
	}
	databaseManager.saveData(fs_adm_t700_sql_params);
}